// Package orders 包含相关的模型定义
// @author 5title_
// @date 2025-04-01
package orders

import (
	"5title_gin/internal/model"
)

// Orders
type Orders struct {
	model.Models

	OrderNumber string `gorm:"column:order_number;comment:订单号" json:"orderNumber"`

	UserId int `gorm:"column:user_id;comment:用户ID" json:"userId"`

	UserName string `gorm:"column:user_name;comment:用户名" json:"userName"`

	GoodsId int `gorm:"column:goods_id;comment:商品ID" json:"goodsId"`
}

// TableName 设置表名
func (Orders) TableName() string {
	return "orders"
}

// OrdersResponse 响应对象
type OrdersResponse struct {
	*Orders
	// 这里可以添加额外的字段
}

// ToOrdersResponse 将模型转换为响应对象
func (m *Orders) ToOrdersResponse() *OrdersResponse {
	if m == nil {
		return nil
	}

	return &OrdersResponse{
		Orders: m,
	}
}

// ToOrdersResponseList 将模型列表转换为响应对象列表
func ToOrdersResponseList(models []*Orders) []*OrdersResponse {
	list := make([]*OrdersResponse, 0, len(models))
	for i := range models {
		list = append(list, models[i].ToOrdersResponse())
	}
	return list
}
